﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace week12
{
    public partial class Form1 : Form
    {
        private   Form2 AForm;
        public Form1()
        {
            InitializeComponent();
        }

        private void Min_exit_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void Min_Win_Newwin_Click(object sender, EventArgs e)
        {
            Form aForm = new Form();
            aForm.Text = string.Format("Mdi Window {0}", this.MdiChildren.Count() + 1);
            aForm.Width = 450;
            aForm.MdiParent = this;
            aForm.Show();
        }

        private void Min_Win_Closewin_Click(object sender, EventArgs e)
        {
            this.ActiveMdiChild.Close();
        }

        private void Min_Win_division_V_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.TileVertical);
        }

        private void Min_Win_division_H_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void Min_Win_stack_Click(object sender, EventArgs e)
        {
            this.LayoutMdi(MdiLayout.Cascade);
        }

        private void Min_Forms2_Open_Click(object sender, EventArgs e)
        {
            if (AForm == null)
            {
                AForm = new Form2();
                AForm.MdiParent = this;
                AForm.Show();
            }
           
        }

        private void Min_Forms2_Close_Click(object sender, EventArgs e)
        {
            AForm.Close();
            AForm = null;
        }
    }
}
